package com.yy.base.common.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yy.base.page.Message;

@Controller
@RequestMapping("/error")
public class ErrorController {
	@ResponseBody
	@Transactional(rollbackFor=RuntimeException.class)
	@RequestMapping(value="/404")
	public Message error404(HttpServletRequest request, HttpServletResponse response){
		Message message = new Message();
		String msg = (String)request.getAttribute("msg");
		if (msg == null) {
			try {
				response.sendRedirect(request.getContextPath() + "/common/404.jsp");
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		}
		message.setData("msg", msg);
		return message;
	}
}
